Skip to content

CFE-4665: cfengine dev format docs should tell you what files it formatted#144

Open
sarakthon wants to merge 1 commit into
cfengine:mainfrom
sarakthon:print-formatted-files
Open

CFE-4665: cfengine dev format docs should tell you what files it formatted#144
sarakthon wants to merge 1 commit into
cfengine:mainfrom
sarakthon:print-formatted-files

Conversation

@sarakthon

@sarakthon sarakthon commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Ticket: CFE-4665

Made a test.py, test.md and test2.md that needs reformatting:
test.py:

x = {"a":1,"b":2,"c":[1,2,3]}

test.md:

# Test
testing     with wrong   spacing.


- test   one
- test two

And test2.md with wrongly formatted json.

Command and output before changes:

% cfengine dev format-docs
Note: This command is intended to be run in the documentation repo
      https://github.com/cfengine/documentation
Continue? (Y/n): y
Formatting with black...
Formatting with prettier...
Formatting code blocks in '.'...

Command and output after changes:
First run with unformatted files:

% cfengine dev format-docs
Note: This command is intended to be run in the documentation repo
      https://github.com/cfengine/documentation
Continue? (Y/n): y
Formatting with black...
File '/Users/sarakristiansdottirthon/Documents/NT/cfengine-cli/test.py' was reformatted
Formatting with prettier...
File '/Users/sarakristiansdottirthon/Documents/NT/cfengine-cli/test.md' was reformatted
Formatting code blocks in '.'...
File '/Users/sarakristiansdottirthon/Documents/NT/cfengine-cli/test2.md' was reformatted

Second run:

% cfengine dev format-docs
Note: This command is intended to be run in the documentation repo
      https://github.com/cfengine/documentation
Continue? (Y/n): y

Added a trailing newline in fn_extract for correct pretty_file diffing, else it would always return True even though the file wasn't reformatted.
Also moved the Formatting with {...} prints inside the actual formatting functions, so they only print if something is reformatted.

@cf-bottom

Copy link
Copy Markdown

Thank you for submitting a PR! Maybe @larsewi can review this?

@larsewi larsewi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

Comment thread src/cfengine_cli/docs.py
Comment thread src/cfengine_cli/docs.py
Comment thread src/cfengine_cli/docs.py Outdated
@sarakthon sarakthon force-pushed the print-formatted-files branch from e258eec to eabbd82 Compare June 10, 2026 11:12
@sarakthon sarakthon requested a review from olehermanse June 10, 2026 11:14
@sarakthon sarakthon marked this pull request as draft June 11, 2026 08:47

@olehermanse olehermanse left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned yesterday, let's try to make the formatting functions return the true/false value we need to know if something was reformatted or not.

Also, please make a comment / edit the first comment (PR description) to show it working (command and output in a code block). Show what you've been testing, and how it was before and after your changes.

@sarakthon sarakthon force-pushed the print-formatted-files branch 2 times, most recently from 2ba2ceb to a451365 Compare June 12, 2026 12:33
@sarakthon sarakthon force-pushed the print-formatted-files branch from a451365 to fc9469f Compare June 12, 2026 12:37
@sarakthon sarakthon marked this pull request as ready for review June 12, 2026 12:40
@sarakthon sarakthon requested a review from olehermanse June 12, 2026 12:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants